package com.twu.biblioteca;

public class Movie {

    private final String title;

    private final int year;

    private final String director;

    private int rating = Integer.MIN_VALUE;

    public Movie(String title, int year, String director) {
        this.title = title;
        this.year = year;
        this.director = director;
    }

    public void setRating(int rating) {
        if (rating < 1 || rating > 10) {
            throw new IllegalArgumentException();
        }
        this.rating = rating;
    }

    public String getTitle() {
        return title;
    }

    public int getYear() {
        return year;
    }

    public String getDirector() {
        return director;
    }

    public int getRating() {
        if (hasRating() == false) {
            throw new IllegalStateException();
        }
        return rating;
    }

    public boolean hasRating() {
        return rating != Integer.MIN_VALUE;
    }

}
